/**
 * Date Created: Apr 15, 2009
 */

package forteresce.portprofile.gui.panels;

import java.awt.Component;
import java.awt.Dimension;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;

import forteresce.portprofile.config.constants.ProfileConstants;

/**
 * A simple panel to be used as a waiting card 
 * @author forteresce
 */
public class WaitPanel extends JPanel {
	private static String DEFAULT_MESSAGE = "Please Wait...";
	private JLabel waitLabel;
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -3439515683761406325L;

	public WaitPanel() {
		super();
		
		//the regular ones
		setMinimumSize(ProfileConstants.MAIN_PANEL_DIM);
		setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
		
		addComponents();
	}

	private void addComponents() {
		//XXX: Debating as to go with this or a loading image
		waitLabel = new JLabel("Please Wait...");
		waitLabel.setAlignmentX(Component.CENTER_ALIGNMENT);

		JProgressBar waitBar = new JProgressBar();
		waitBar.setMaximumSize(new Dimension(200, 20));
		waitBar.setAlignmentX(Component.CENTER_ALIGNMENT);
		waitBar.setIndeterminate(true);

		add(Box.createRigidArea(new Dimension(0,25)));
		add(waitLabel, Component.CENTER_ALIGNMENT);
		add(Box.createRigidArea(new Dimension(0,25)));
		add(waitBar, Component.CENTER_ALIGNMENT);
	}
	
	/**
	 * @param message to be set for the wait label
	 */
	public void setMessage(String message) {
		waitLabel.setText((null != message && !"".equals(message)) ? message : DEFAULT_MESSAGE);
	}

}
